#include "netdisk.h"

int socket_client(){
    int fd;
    struct sockaddr_in  client_addr;
    fd=socket(AF_INET,SOCK_STREAM,0);
    //对端口进行初步设置
    memset(&client_addr,0,sizeof(client_addr));
    client_addr.sin_family=AF_INET;
    client_addr.sin_port=htons(2000);
    client_addr.sin_addr.s_addr=inet_addr("192.168.253.128");
    int reuse=1;
    int ret;
    // 进行连接设置
    ret=setsockopt(fd,SOL_SOCKET,SO_REUSEADDR,(void*)&reuse,sizeof(int));
    ERROR_CHECK(ret,-1,"setsockopt")
    ret=connect(fd,(struct sockaddr*)&client_addr,sizeof(struct sockaddr));
    ERROR_CHECK(ret,-1,"connect")
    return fd;
}